package syan.kafkastream.Listener;

import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.Message;
import syan.kafkastream.Service.EsChannel;

/**
 * @author CHENTAIWEN
 * @create 2022/8/24 15:07
 */
@Slf4j
@EnableBinding(value = EsChannel.class)
public class EsKafkaMessageReceiveListener {

    @StreamListener(EsChannel.STREAM_DEMO1_INPUT)
    public void receive(Message<String> message){
        log.info("{}订阅告警消息：通道 = demo1，data = {}", DateUtil.now(), message);
    }

    @StreamListener(EsChannel.STREAM_DEMO2_INPUT)
    public void receiveAlarm(Message<String> message){
        log.info("{}订阅告警消息：通道 = demo2，data = {}", DateUtil.now(), message);
    }
}
